(function(window, document) {
    angular
        .module('app')
        .config(config);

    config.$inject = [
        '$stateProvider',
        '$urlRouterProvider',
        '$cookiesProvider',
        '$httpProvider',
        'lazyImgConfigProvider'
    ];

    function config ($stateProvider, $urlRouterProvider, $cookiesProvider, $httpProvider, lazyImgConfigProvider) {
        $urlRouterProvider
            .otherwise('/account-list');

        $stateProvider
            .state('accountList', {
                url: '/account-list',
                templateUrl: 'assets/partials/accountList.html',
                controller: 'accountListController as alc'
            })
            .state('accountDaylist', {
                url: '/account-daylist/:accountid',
                templateUrl: 'assets/partials/accountDaylist.html',
                controller: 'accountDaylistController as adlc'
            })
            .state('accountDaylist.details', {
                url: '/:accountdayid',
                templateUrl: 'assets/partials/accountDaylist.details.html',
                controller: 'accountDetailController as adc'
            })
            .state('accountDaylist.details.payok', {
                url: '/:key',
                templateUrl: 'assets/partials/accountDaylist.details.payok.html',
                controller: 'accountPayokController as apc'
            })
            // 支付状态回调接口
            .state('payCallback', {
                url: '/paycallback?orderid&payorderid&paytype&sign',
                controller: 'payCallbackController'
            });

        $cookiesProvider.defaults = {
        //     path: yourPath,
        //     domain: yourDomain,
        //     expires: expiresDate,
        //     secure: true/false
        };
        // console.log($cookies.defaults);

        // 配置拦截器
        $httpProvider.interceptors.push('loadingInterceptor');

        // 配置图片延迟加载
        lazyImgConfigProvider.setOptions({
            // offset: 100,
            // errorClass: 'error',
            // successClass: 'success',
            // onError: function(image){},
            // onSuccess: function(image){},
            // container: angular.element(scrollable)
        });
    }
})(window, document);

